/**
 * Created by ClearLiang on 2019/2/23
 * Function:
 * Desc:
 */
import React, {Component} from 'react';
import {Button, StyleSheet, View, Text, TextInput} from 'react-native';
import {localAge, localName} from './mycomp/EIComponent';
import XiaoMing from './myclass/XiaoMing';
import MyList from './mycomp/MyList'
import MyToolbarAndroid from './mycomp/MyToolbarAndroid'
import StateComponent from './mycomp/StateComponent'



function helloWorld (ready) {
    return new Promise(function (resolve, reject) {
        if (ready) {
            resolve("Hello World!");
        } else {
            reject("Good bye!");
        }
    });
}
//{city: "杭州", country: "中国", ip: "115.216.103.138", province: "浙江"}

export default class App extends Component {

    constructor(props) {
        super(props);
        this.state = {
            text: true,
            res: '',
            remove: false,
        };
        this.user1 = new XiaoMing('会计')
        this.user2 = new XiaoMing('小红',55,'女','计算机')
    }

    render() {

        return (
            <View>
                <MyToolbarAndroid/>
            </View>
        );
    }
}


const styles = StyleSheet.create({
    styleContainer:{
        flex: 1,
        flexDirection: 'column',
        justifyContent: 'space-between',
        alignItems: 'flex-start',
        flexWrap: 'wrap',
    },
    style1: {
        color: 'green',
        alignItems: 'center',
        fontSize: 20,
    },
    bigBlue: {
        fontWeight: 'bold',
        fontSize: 30,
    },
    red: {
        fontSize: 30,
        color: 'red',
    },
    container: {
        flex: 1,
        backgroundColor: '#F5FCFF',
        padding: 10,
    },
    scottStyle: {
        flex: 1,
        backgroundColor: '#F5FCFF',
        justifyContent: 'center',
        alignItems: 'center',
    },
    textStyle: {
        height: 100, width: 200, color: 'pink', fontSize: 30
    }
});

// ①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳{this.user2.getDesc()}
//let isRemove = this.state.remove ? null : <Text>{this.user1.getDesc()}</Text>;
//let text = this.state.text ? "显示" : "隐藏";
//let params = {city:'hangzhou',province:'zhejiang',country:'china'};
//let {country,city} = params;
//let data1 = [{key: 'a'},{key: 'b'},{key: 'c'},{key: 'd'},{key: 'e'}];
//<View style={styles.container}>
//    <Button
//        onPress={() => {
//            Alert.alert("你点击了按钮！");
//            this.setState({
//                remove: !this.state.remove,
//                text: !this.state.text,
//            });
//            helloWorld(true)
//                .then(function (message) {
//                    //http://apicloud.mob.com/ip/query?key=2940613d85d74&ip=115.216.103.138
//                    //{"msg":"success","result":{"city":"杭州","country":"中国","ip":"115.216.103.138","province":"浙江"},"retCode":"200"}
//                    let REQUEST_URL = 'http://apicloud.mob.com/ip/query?key=2940613d85d74&ip=115.216.103.138';
//                    return  fetch(REQUEST_URL)
//                        .then((response) => response.json())
//                        .then((responseData) => {
//                            let address = responseData.result;
//                            console.log(responseData,address.city,message);
//                            return address.city;
//                        })},function (error) {return(error);
//                })
//                .then(function (message) {
//                    return message  + ' World';
//                })
//                .then(function (message) {
//                    return message + '!!!';
//                })
//                .then(function (message) {
//                    console.log(message);
//                    console.log('finally');
//                })
//                .catch(function(error){
//                    console.log(error);
//                });
//        }}
//        title={text}
//    />
//    { <Text>{this.user1.getDesc()}</Text>}
//    { <Text>{this.user2.getDesc()}</Text>}
//    { <MyList data={data1}/>}
//    <TextInput
//                    style={{height: 40, backgroundColor: "#FFFDDD"}}
//                    placeholder="Type here to translate!"
//                    onChangeText={
//                        (text) => {
//                           this.setState(() => {
//                               return {
//                                   text: text,
//                                   res:text,
//                               };
//                           });
//                       }
//                   }
//                   onSubmitEditing={() => {
//                       alert(this.state.text);
//                   }}
//               />
//               <Text style={{padding: 10, fontSize: 42}}>
//                   {
//                       this.state.res.split(' ')                       //返回一个以空格分开的数组
//                           .map((word) => word && '🍕')
//                           //.map(getData)     //var aa = a1 && a2 && a3; 3个条件连接起来判断真假,都为真 则返回最后一个值,aa结果为a3；
//                           .join('||')
//                   }
//               </Text>
//</View>